package com.wanlian.router.ui.me;

import android.view.View;

import com.wanlian.router.R;
import com.wanlian.router.ui.WlBaseActivity;
import com.wanlian.router.ui.router.RouterDeviceSettingActivity;

/**
 * Created by Hyu on 2018/9/8.
 * Email: fvaryu@163.com
 */
//@RuntimePermissions
public class MyDeviceActivity extends WlBaseActivity {


    @Override
    protected int layout() {
        return R.layout.activity_fragment;
    }

    @Override
    public void initUI() {
        super.initUI();
        setTitle("我的设备");

        setNextImage(R.drawable.btn_add_router);
        setNextClickLisener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                redirectActivity(RouterDeviceSettingActivity.class);
//                MyDeviceActivityPermissionsDispatcher.openCameraWithPermissionCheck(MyDeviceActivity.this);
            }
        });
    }

    @Override
    public void initData() {
        super.initData();

        showFragment(MyDeviceFragment.newInstance(), "_device");
    }

/*
    @NeedsPermission(Manifest.permission.CAMERA)
    void openCamera() {
        redirectActivity(BindDeviceActivity.class);
    }

    @OnShowRationale(Manifest.permission.CAMERA)
    void showRationaleForCamera(final PermissionRequest request) {
        new AlertDialog.Builder(this)
                .setTitle(R.string.ask_permission)
                .setMessage(R.string.tip_camera_permission)
                .setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        request.cancel();
                    }
                }).setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                request.proceed();
            }
        }).setCancelable(false).create().show();
    }


    void askCamera() {
        new AlertDialog.Builder(this)
                .setTitle(R.string.ask_permission)
                .setMessage(R.string.tip_camera_permission)
                .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                }).setPositiveButton(R.string.to_setting, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
                startActivity(intent);
                finish();
            }
        }).setCancelable(false).create().show();
    }

    @OnPermissionDenied(Manifest.permission.CAMERA)
    void onDeniedForLocation() {
        askCamera();
    }

    @OnNeverAskAgain(Manifest.permission.CAMERA)
    void onNeverAskAgain() {
        askCamera();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        MyDeviceActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }
    */
}
